<template>
  <div id="firstRegistration">
    <div class="form-box">
      <el-form
        ref="ruleForm"
        :model="ruleForm"
        :rules="rules"
        label-width="130px"
        class="demo-ruleForm"
      >
        <el-form-item label="首次注册，可获得" prop="getIntegral" class="small">
          <el-input-number
            v-model.number="ruleForm.getIntegral"
            size="mini"
            :min="1"
            :max="9999"
            :controls="false"
            :step="1"
            step-strictly
          ></el-input-number>
          积分
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
export default {
  name: 'firstRegistration',
  msg: '首次注册',
  data() {
    return {
      ruleForm: {
        getIntegral: 0 // 首次注册获得积分
      },
      rules: {
        getIntegral: {
          type: 'number',
          required: true,
          message: '积分不能为空',
          trigger: 'change'
        }
      }
    }
  },
  mounted() {},
  methods: {
    //表单赋值
    setForm(formData) {
      let { getIntegral } = formData
      this.ruleForm = {
        getIntegral
      }
    },
    //表单校验 & 数据提交
    checkForm() {
      this.$emit('setComRuleForm', this.ruleForm)
      let _this = this
      return new Promise((resolve, reject) => {
        _this.$refs.ruleForm.validate(async (valid) => {
          if (valid) {
            resolve(true)
          } else {
            reject(false)
          }
        })
      })
    }
  }
}
</script>

<style lang="less">
#firstRegistration {
}
</style>
